#进阶
my_list = [3, "apple", 9, "banana", 7, "cherry", 2, "date", 5, "elderberry"]
#1
my_list.append('fig')
print(my_list)
#2
my_list.remove('banana')
print(my_list)
#3
my_list[6]='grape'
print(my_list)
#4
i=0
for e in my_list:
    if e=='cherry':
        print(i)
    i+=1
#5
for e in my_list:
    print(e)
#6
index=my_list.index('cherry')
my_list.insert(index+1,'kiwi')
print(my_list)
#7
print(my_list[2])
#8
print(my_list[-2])
#9
print(my_list[2:7:1])
#10
print(my_list[-1::-1])
#11
str1=[]
print(my_list)
for a in my_list:
    if isinstance(a,str):
        str1.append(a)
new_list=sorted(str1)
print(new_list)
list1=my_list
i=0
j=0
for e in my_list:
    if isinstance(e,str):
        list1[j]=new_list[i]
        i+=1
    j+=1
print(list1)
#12将my_list中的数字替换为它们对应的字符串形式（如1->'one'），不改变列表中原有的字符串。
num_word= {0: 'zero', 1: 'one', 2: 'two', 3: 'three', 4: 'four',    5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine',    10: 'ten'}
print(my_list)
l=[]
for e in my_list:
    if isinstance(e,int) and type(e) is int:
        l.append(num_word.get(e,e))
    else:
        l.append(e)
print(l)





























